Remove pointless inout arguments
authorEmmanuele Bassi <ebassi@gnome.org>
Tue, 17 Nov 2020 14:40:52 +0000 (14:40 +0000)
committerEmmanuele Bassi <ebassi@gnome.org>
Tue, 17 Nov 2020 16:38:12 +0000 (16:38 +0000)
GtkTreeView.get_tooltip_context() takes an inout X and Y coordinates,
but the "out" side is a side effect: the conversion from widget-relative
to bin window-relative coordinates is not documented, and can be done
using public API, if needed.

GtkIconView.get_tooltip_context() follows the same pattern, and takes
two inout arguments for the coordinates, but it does not change them any
more, after GtkIconView's bin window was dropped in commit 8dc5e13e.

There's really no point in having these `inout` arguments, and while
GtkTreeView and GtkIconView are certainly de-emphasised in GTK4, and we
nudge developers to move to the new list views, we should take advantage
of the API break to remove warts.

docs/reference/gtk/migrating-3to4.md
gtk/gtkfilechooserwidget.c
gtk/gtkiconview.c
gtk/gtkiconview.h
gtk/gtktreeview.c
gtk/gtktreeview.h
tests/testtooltips.c

index 14591ecb86186d84c0a9f4e5d48c350203c2dcee..8a4fc9f32e1201ecff60684e956efec8c9b3850d 100644 (file)
@@ -1136,6 +1136,14 @@ gtk_buildable_get_buildable_id().
 GtkAboutDialog now directly derives from GtkWindow, the GtkDialog API can no
 longer be used on it.
 
+### Adapt to GtkTreeView and GtkIconView tooltip context changes
+
+The getter functions for retrieving the data from #GtkTreeView
+and #GtkIconView inside a #GtkWidget::query-tooltip signal do not take the
+pointer coordinates as inout arguments any more, but as normal in ones.
+
+See: gtk_tree_view_get_tooltip_context(), gtk_icon_view_get_tooltip_context()
+
 ## Changes to consider after the switch
 
 GTK 4 has a number of new features that you may want to take
index b063dd7a6019cefdd246a3dc888f416ae1ff5cb3..dd1cb284cfdcfa0c77a0a76bce2f334be6d4d959 100644 (file)
@@ -2111,7 +2111,7 @@ file_list_query_tooltip_cb (GtkWidget  *widget,
 
 
   if (!gtk_tree_view_get_tooltip_context (GTK_TREE_VIEW (impl->browse_files_tree_view),
-                                          &x, &y,
+                                          x, y,
                                           keyboard_tip,
                                           &model, &path, &iter))
     return FALSE;
index ac4912a06e8ca5d8934a7a1292fd89c89b9f6fd8..5d24c1f0bf9ea983d23c845af63b682764273e6e 100644 (file)
@@ -4254,8 +4254,8 @@ gtk_icon_view_set_tooltip_cell (GtkIconView     *icon_view,
 /**
  * gtk_icon_view_get_tooltip_context:
  * @icon_view: an #GtkIconView
- * @x: (inout): the x coordinate (relative to widget coordinates)
- * @y: (inout): the y coordinate (relative to widget coordinates)
+ * @x: the x coordinate (relative to widget coordinates)
+ * @y: the y coordinate (relative to widget coordinates)
  * @keyboard_tip: whether this is a keyboard tooltip or not
  * @model: (out) (allow-none) (transfer none): a pointer to receive a
  *         #GtkTreeModel or %NULL
@@ -4277,8 +4277,8 @@ gtk_icon_view_set_tooltip_cell (GtkIconView     *icon_view,
  */
 gboolean
 gtk_icon_view_get_tooltip_context (GtkIconView   *icon_view,
-                                   int           *x,
-                                   int           *y,
+                                   int            x,
+                                   int            y,
                                    gboolean       keyboard_tip,
                                    GtkTreeModel **model,
                                    GtkTreePath  **path,
@@ -4287,8 +4287,6 @@ gtk_icon_view_get_tooltip_context (GtkIconView   *icon_view,
   GtkTreePath *tmppath = NULL;
 
   g_return_val_if_fail (GTK_IS_ICON_VIEW (icon_view), FALSE);
-  g_return_val_if_fail (x != NULL, FALSE);
-  g_return_val_if_fail (y != NULL, FALSE);
 
   if (keyboard_tip)
     {
@@ -4299,7 +4297,7 @@ gtk_icon_view_get_tooltip_context (GtkIconView   *icon_view,
     }
   else
     {
-      if (!gtk_icon_view_get_item_at_pos (icon_view, *x, *y, &tmppath, NULL))
+      if (!gtk_icon_view_get_item_at_pos (icon_view, x, y, &tmppath, NULL))
         return FALSE;
     }
 
@@ -4333,7 +4331,7 @@ gtk_icon_view_set_tooltip_query_cb (GtkWidget  *widget,
   GtkIconView *icon_view = GTK_ICON_VIEW (widget);
 
   if (!gtk_icon_view_get_tooltip_context (GTK_ICON_VIEW (widget),
-                                          &x, &y,
+                                          x, y,
                                           keyboard_tip,
                                           &model, &path, &iter))
     return FALSE;
index 022b455188d204232748b371966b7341cabe4d3c..7a204b54d9710cc3029364858416b694759c2bfc 100644 (file)
@@ -268,8 +268,8 @@ void    gtk_icon_view_set_tooltip_cell                        (GtkIconView     *
                                                                GtkCellRenderer *cell);
 GDK_AVAILABLE_IN_ALL
 gboolean gtk_icon_view_get_tooltip_context                    (GtkIconView       *icon_view,
-                                                               int               *x,
-                                                               int               *y,
+                                                               int                x,
+                                                               int                y,
                                                                gboolean           keyboard_tip,
                                                                GtkTreeModel     **model,
                                                                GtkTreePath      **path,
index 8cfb238debd4fa5a0b657acbbf279079de158d6d..f404eec9e467d7b77b0429e520377196e4975826 100644 (file)
@@ -14676,8 +14676,8 @@ gtk_tree_view_set_tooltip_cell (GtkTreeView       *tree_view,
 /**
  * gtk_tree_view_get_tooltip_context:
  * @tree_view: a #GtkTreeView
- * @x: (inout): the x coordinate (relative to widget coordinates)
- * @y: (inout): the y coordinate (relative to widget coordinates)
+ * @x: the x coordinate (relative to widget coordinates)
+ * @y: the y coordinate (relative to widget coordinates)
  * @keyboard_tip: whether this is a keyboard tooltip or not
  * @model: (out) (optional) (nullable) (transfer none): a pointer to
  *         receive a #GtkTreeModel or %NULL
@@ -14700,8 +14700,8 @@ gtk_tree_view_set_tooltip_cell (GtkTreeView       *tree_view,
  */
 gboolean
 gtk_tree_view_get_tooltip_context (GtkTreeView   *tree_view,
-                                  int           *x,
-                                  int           *y,
+                                  int            x,
+                                  int            y,
                                   gboolean       keyboard_tip,
                                   GtkTreeModel **model,
                                   GtkTreePath  **path,
@@ -14710,8 +14710,6 @@ gtk_tree_view_get_tooltip_context (GtkTreeView   *tree_view,
   GtkTreePath *tmppath = NULL;
 
   g_return_val_if_fail (GTK_IS_TREE_VIEW (tree_view), FALSE);
-  g_return_val_if_fail (x != NULL, FALSE);
-  g_return_val_if_fail (y != NULL, FALSE);
 
   if (keyboard_tip)
     {
@@ -14722,10 +14720,12 @@ gtk_tree_view_get_tooltip_context (GtkTreeView   *tree_view,
     }
   else
     {
-      gtk_tree_view_convert_widget_to_bin_window_coords (tree_view, *x, *y,
-                                                         x, y);
+      int rel_x, rel_y;
 
-      if (!gtk_tree_view_get_path_at_pos (tree_view, *x, *y,
+      gtk_tree_view_convert_widget_to_bin_window_coords (tree_view, x, y,
+                                                         &rel_x, &rel_y);
+
+      if (!gtk_tree_view_get_path_at_pos (tree_view, rel_x, rel_y,
                                          &tmppath, NULL, NULL, NULL))
        return FALSE;
     }
@@ -14762,7 +14762,7 @@ gtk_tree_view_set_tooltip_query_cb (GtkWidget  *widget,
   GtkTreeViewPrivate *priv = gtk_tree_view_get_instance_private (tree_view);
 
   if (!gtk_tree_view_get_tooltip_context (GTK_TREE_VIEW (widget),
-                                         &x, &y,
+                                         x, y,
                                          keyboard_tip,
                                          &model, &path, &iter))
     return FALSE;
index c323c7d957dd1f23dae642afe6f1396bb374cb11..0910ad23ac733e082625b99e2109cf788bbd2050 100644 (file)
@@ -528,8 +528,8 @@ void          gtk_tree_view_set_tooltip_cell   (GtkTreeView       *tree_view,
                                                GtkCellRenderer   *cell);
 GDK_AVAILABLE_IN_ALL
 gboolean      gtk_tree_view_get_tooltip_context(GtkTreeView       *tree_view,
-                                               int               *x,
-                                               int               *y,
+                                               int                x,
+                                               int                y,
                                                gboolean           keyboard_tip,
                                                GtkTreeModel     **model,
                                                GtkTreePath      **path,
index 2cc4bf9c96b91526700f7cb5a48c7945dd783e75..80f60b67ccda3a9c5ed78733b63239164b2665e1 100644 (file)
@@ -125,7 +125,7 @@ query_tooltip_tree_view_cb (GtkWidget  *widget,
 
   char buffer[512];
 
-  if (!gtk_tree_view_get_tooltip_context (tree_view, &x, &y,
+  if (!gtk_tree_view_get_tooltip_context (tree_view, x, y,
                                          keyboard_tip,
                                          &model, &path, &iter))
     return FALSE;